//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================

#ifndef __FLOAT_H__
#define __FLOAT_H__

#ifdef  __cplusplus
extern  "C" {
#endif

/* IEEE 754 classication */
#define _FPCLASS_SNAN   0x0001 /* signaling NaN */
#define _FPCLASS_QNAN   0x0002 /* quiet NaN */
#define _FPCLASS_NINF   0x0004 /* negative infinity */
#define _FPCLASS_NN     0x0008 /* negative normal */
#define _FPCLASS_ND     0x0010 /* negative denormal */
#define _FPCLASS_NZ     0x0020 /* -0 */
#define _FPCLASS_PZ     0x0040 /* +0 */
#define _FPCLASS_PD     0x0080 /* positive denormal */
#define _FPCLASS_PN     0x0100 /* positive normal */
#define _FPCLASS_PINF   0x0200 /* positive infinity */

#define FP_SNAN         0x0001  //signaling NaN
#define FP_QNAN         0x0002  //quiet NaN
#define FP_NINF         0x0004  //negative infinity
#define FP_PINF         0x0200  //positive infinity
#define FP_NDENORM      0x0008  //negative denormalized non-zero
#define FP_PDENORM      0x0010  //positive denormalized non-zero
#define FP_NZERO        0x0020  //negative zero
#define FP_PZERO        0x0040  //positive zero
#define FP_NNORM        0x0080  //negative normalized non-zero
#define FP_PNORM        0x0100  //positive normalized non-zero

#define FLT_RADIX       2           /* b */
#define FLT_ROUNDS      1           /* FP addition rounds to nearest */

#define FLT_MANT_DIG    24          /* p */
#define FLT_EPSILON     1.19209290E-07F /* b**(1 - p) */
#define FLT_DIG         6           /* floor((p - 1)*log10(b)) + (b == 10) */
#define FLT_MIN_EXP     (-125)      /* emin */
#define FLT_MIN         1.17549435E - 38F /* b**(emin - 1) */
#define FLT_MIN_10_EXP  (-37)       /* ceil(log10(b**(emin - 1))) */
#define FLT_MAX_EXP     128         /* emax */
#define FLT_MAX         3.40282347E+38F /* (1 - b**(-p))*b**emax */
#define FLT_MAX_10_EXP  38          /* floor(log10((1 - b**(-p))*b**emax)) */

#define DBL_MANT_DIG    53
#define DBL_EPSILON     2.2204460492503131E-16
#define DBL_DIG         15
#define DBL_MIN_EXP     (-1021)
#define DBL_MIN         2.2250738585072014E-308
#define DBL_MIN_10_EXP  (-307)
#define DBL_MAX_EXP     1024
#define DBL_MAX         1.7976931348623157E+308
#define DBL_MAX_10_EXP  308

#define LDBL_MANT_DIG   DBL_MANT_DIG
#define LDBL_EPSILON    DBL_EPSILON
#define LDBL_DIG        DBL_DIG
#define LDBL_MIN_EXP    DBL_MIN_EXP
#define LDBL_MIN        DBL_MIN
#define LDBL_MIN_10_EXP DBL_MIN_10_EXP
#define LDBL_MAX_EXP    DBL_MAX_EXP
#define LDBL_MAX        DBL_MAX
#define LDBL_MAX_10_EXP DBL_MAX_10_EXP

typedef int fpclass_t;

double     __cdecl  _copysign(double, double);
double     __cdecl  _scalb(double, long);
double     __cdecl  _logb(double);
int        __cdecl  _isnan(double);
int        __cdecl  _finite(double);
fpclass_t  __cdecl  _fpclass (double);
double     __cdecl  _nextafter(double, double);

//POSIX
double     __cdecl  copysign(double, double);
int        __cdecl  isnan(double);
int        __cdecl  isfinite(double);
int        __cdecl  isinf(double);
fpclass_t  __cdecl  fpclass (double);
double     __cdecl  nextafter(double, double);

#ifdef _EVC
#pragma function(_isnan)
#endif


#ifdef  __cplusplus
}
#endif

#endif /* __FLOAT_H__ */
